

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" href="/img/favicon.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Han Qiu">
  <meta name="keywords" content="">
  
    <meta name="description" content="最近看到有些在线文档可以进行签名，以防以后项目中会用到，提前用canvas练习一下，先看下最后实现的效果： 思路 在canva中监听鼠标按下事件（mousedown），获取按下时鼠标到canvas左上角的距离 以鼠标按下的点为canvas画笔的起点，监听鼠标移动事件（mousemove），根据鼠标移动到的位置实时绘制线条 监听鼠标弹起事件（mouseup），移除对mousemove事件的监听，防止">
<meta property="og:type" content="article">
<meta property="og:title" content="canvas实现简易签字板">
<meta property="og:url" content="http://example.com/2022/01/06/canvas%E5%AE%9E%E7%8E%B0%E7%AE%80%E6%98%93%E7%AD%BE%E5%AD%97%E6%9D%BF/index.html">
<meta property="og:site_name" content="寒秋の博客">
<meta property="og:description" content="最近看到有些在线文档可以进行签名，以防以后项目中会用到，提前用canvas练习一下，先看下最后实现的效果： 思路 在canva中监听鼠标按下事件（mousedown），获取按下时鼠标到canvas左上角的距离 以鼠标按下的点为canvas画笔的起点，监听鼠标移动事件（mousemove），根据鼠标移动到的位置实时绘制线条 监听鼠标弹起事件（mouseup），移除对mousemove事件的监听，防止">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/huqian025/my-images/raw/master/demos/canvas%E5%AE%9E%E7%8E%B0%E7%AE%80%E6%98%93%E7%AD%BE%E5%AD%97%E6%9D%BF/%E7%AD%BE%E5%AD%97%E6%9D%BF%E6%95%88%E6%9E%9C.gif">
<meta property="og:image" content="https://gitee.com/huqian025/my-images/raw/master/demos/canvas%E5%AE%9E%E7%8E%B0%E7%AE%80%E6%98%93%E7%AD%BE%E5%AD%97%E6%9D%BF/offsetX%E3%80%81clientX%E3%80%81screenX.png">
<meta property="og:image" content="https://gitee.com/huqian025/my-images/raw/master/demos/canvas%E5%AE%9E%E7%8E%B0%E7%AE%80%E6%98%93%E7%AD%BE%E5%AD%97%E6%9D%BF/%E7%AD%BE%E5%AD%97%E6%9D%BF%E5%AF%BC%E5%87%BA%E4%B8%BA%E5%9B%BE%E7%89%87.gif">
<meta property="article:published_time" content="2022-01-06T03:41:51.000Z">
<meta property="article:modified_time" content="2022-01-06T03:42:34.347Z">
<meta property="article:author" content="Han Qiu">
<meta property="article:tag" content="canvas">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://gitee.com/huqian025/my-images/raw/master/demos/canvas%E5%AE%9E%E7%8E%B0%E7%AE%80%E6%98%93%E7%AD%BE%E5%AD%97%E6%9D%BF/%E7%AD%BE%E5%AD%97%E6%9D%BF%E6%95%88%E6%9E%9C.gif">
  
  
  <title>canvas实现简易签字板 - 寒秋の博客</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4/github-markdown.min.css" />
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hint.css@2/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css" />
  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.8.14","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 6.0.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>blogs</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="canvas实现简易签字板">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2022-01-06 11:41" pubdate>
        2022年1月6日 中午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      2.4k 字
    </span>
  

  
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      20 分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">canvas实现简易签字板</h1>
            
            <div class="markdown-body">
              <p>最近看到有些在线文档可以进行签名，以防以后项目中会用到，提前用canvas练习一下，先看下最后实现的效果：<br><img src="https://gitee.com/huqian025/my-images/raw/master/demos/canvas%E5%AE%9E%E7%8E%B0%E7%AE%80%E6%98%93%E7%AD%BE%E5%AD%97%E6%9D%BF/%E7%AD%BE%E5%AD%97%E6%9D%BF%E6%95%88%E6%9E%9C.gif" srcset="/img/loading.gif" lazyload></p>
<h4 id="思路"><a href="#思路" class="headerlink" title="思路"></a>思路</h4><ol>
<li>在canva中监听鼠标按下事件（<code>mousedown</code>），获取按下时鼠标到canvas左上角的距离</li>
<li>以鼠标按下的点为canvas画笔的起点，监听鼠标移动事件（<code>mousemove</code>），根据鼠标移动到的位置实时绘制线条</li>
<li>监听鼠标弹起事件（<code>mouseup</code>），移除对mousemove事件的监听，防止鼠标弹起继续绘制</li>
</ol>
<h4 id="搭建html结构"><a href="#搭建html结构" class="headerlink" title="搭建html结构"></a>搭建html结构</h4><p>html结构比较简单，直接使用一个canvas标签，设置其背景色，宽度和高度。背景色是为了方便看效果，宽度默认300px，高度默认150px，设置宽高时不用带单位px</p>
<figure class="highlight html"><table><tr><td class="gutter"><div class="code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></div></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">http-equiv</span>=<span class="hljs-string">&quot;X-UA-Compatible&quot;</span> <span class="hljs-attr">content</span>=<span class="hljs-string">&quot;IE=edge&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;viewport&quot;</span> <span class="hljs-attr">content</span>=<span class="hljs-string">&quot;width=device-width, initial-scale=1.0&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>简易签名板<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">canvas</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;background-color: skyblue;&quot;</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;canvas&quot;</span> <span class="hljs-attr">width</span>=<span class="hljs-string">&quot;400&quot;</span> <span class="hljs-attr">height</span>=<span class="hljs-string">&quot;200&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">canvas</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;./canvas.js&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h4 id="在canvas-js中实现功能"><a href="#在canvas-js中实现功能" class="headerlink" title="在canvas.js中实现功能"></a>在canvas.js中实现功能</h4><ol>
<li>获取canvas对象，获取2D画笔<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">const</span> canvas = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">&#x27;#canvas&#x27;</span>)<br><span class="hljs-keyword">if</span> (canvas.getContext) &#123;<br>  <span class="hljs-keyword">const</span> ctx = canvas.getContext(<span class="hljs-string">&#x27;2d&#x27;</span>);<br>&#125;<br></code></pre></td></tr></table></figure></li>
<li>根据鼠标移动绘制路径<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// 监听鼠标按下事件</span><br>canvas.onmousedown = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">mousedownEvent</span>) </span>&#123;<br>  <span class="hljs-comment">// 获取绘制起点，即鼠标点击到canvas元素左上角的距离</span><br>  <span class="hljs-keyword">const</span> startX = mousedownEvent.offsetX;<br>  <span class="hljs-keyword">const</span> startY = mousedownEvent.offsetY;<br>  ctx.beginPath();<br>  <span class="hljs-comment">// 将画笔移动到起点</span><br>  ctx.moveTo(startX, startY);<br><br>  <span class="hljs-comment">// 监听鼠标移动事件</span><br>  canvas.onmousemove = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">mousemoveEvent</span>) </span>&#123;<br>    <span class="hljs-comment">// 跟随鼠标移动来移动画笔</span><br>    ctx.lineTo(mousemoveEvent.offsetX, mousemoveEvent.offsetY);<br>    <span class="hljs-comment">// 实时绘制</span><br>    ctx.stroke();<br>  &#125;<br><br>  <span class="hljs-comment">// 监听鼠标弹起事件</span><br>  canvas.onmouseup = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>&#123;<br>    canvas.onmousemove = <span class="hljs-literal">null</span><br>    <span class="hljs-comment">// 闭合路径，使用之后线条起点和终点会自动连起来</span><br>    <span class="hljs-comment">// ctx.closePath();</span><br>    <span class="hljs-comment">// 鼠标弹起时再绘制</span><br>    <span class="hljs-comment">// ctx.stroke();</span><br>  &#125;<br><br>  <span class="hljs-comment">// 监听鼠标移出canvas区域事件</span><br>  canvas.onmouseout = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>&#123;<br>    <span class="hljs-comment">// 鼠标移出时，停止对mousemove事件的监听，否则在移出时鼠标弹起事件监听失效</span><br>    canvas.onmousemove = <span class="hljs-literal">null</span><br>  &#125;<br>&#125;<br></code></pre></td></tr></table></figure></li>
</ol>
<p><strong>注意点clientX/Y和offsetX/Y</strong><br><img src="https://gitee.com/huqian025/my-images/raw/master/demos/canvas%E5%AE%9E%E7%8E%B0%E7%AE%80%E6%98%93%E7%AD%BE%E5%AD%97%E6%9D%BF/offsetX%E3%80%81clientX%E3%80%81screenX.png" srcset="/img/loading.gif" lazyload></p>
<h4 id="扩展：将canvas转化为图片"><a href="#扩展：将canvas转化为图片" class="headerlink" title="扩展：将canvas转化为图片"></a>扩展：将canvas转化为图片</h4><ul>
<li>方法一：使用<a target="_blank" rel="noopener" href="https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLCanvasElement/toDataURL">HTMLCanvasElement.toDataURL()</a>获取canvas图片的dataURL</li>
<li>方法二：使用<a target="_blank" rel="noopener" href="https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLCanvasElement/toBlob">HTMLCanvasElement.toBlob()</a>创建Blob对象，再使用<a target="_blank" rel="noopener" href="https://developer.mozilla.org/zh-CN/docs/Web/API/URL/createObjectURL">URL.createObjectURL()</a>获取指向该Blob对象的URL<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// 按钮点击事件</span><br>btn.onclick = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>&#123;<br>  <span class="hljs-comment">// 方法一</span><br>  <span class="hljs-keyword">const</span> canvasData = canvas.toDataURL()<br>  <span class="hljs-keyword">const</span> img = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&#x27;img&#x27;</span>)<br>  img.src=canvasData;<br>  body.appendChild(img)<br><br>  <span class="hljs-comment">// 方法二</span><br>  <span class="hljs-comment">// canvas.toBlob(function(blob) &#123;</span><br>  <span class="hljs-comment">//   var url = URL.createObjectURL(blob);</span><br>  <span class="hljs-comment">//   const img = document.createElement(&#x27;img&#x27;)</span><br>  <span class="hljs-comment">//   img.src=url;</span><br>  <span class="hljs-comment">//   // 图片加载成功后清除url，避免占用内存</span><br>  <span class="hljs-comment">//   img.onload = function() &#123;</span><br>  <span class="hljs-comment">//     URL.revokeObjectURL(url)</span><br>  <span class="hljs-comment">//   &#125;;</span><br>  <span class="hljs-comment">//   body.appendChild(img)</span><br>  <span class="hljs-comment">// &#125;)</span><br>&#125;<br></code></pre></td></tr></table></figure>
<img src="https://gitee.com/huqian025/my-images/raw/master/demos/canvas%E5%AE%9E%E7%8E%B0%E7%AE%80%E6%98%93%E7%AD%BE%E5%AD%97%E6%9D%BF/%E7%AD%BE%E5%AD%97%E6%9D%BF%E5%AF%BC%E5%87%BA%E4%B8%BA%E5%9B%BE%E7%89%87.gif" srcset="/img/loading.gif" lazyload></li>
</ul>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/categories/canvas/">canvas</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/canvas/">canvas</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/01/06/dos%E4%BF%AE%E6%94%B9%E9%BB%98%E8%AE%A4%E7%BC%96%E7%A0%81%E6%A0%BC%E5%BC%8F/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">dos修改默认编码格式</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2022/01/06/vue%E8%AE%A1%E7%AE%97%E5%B1%9E%E6%80%A7computed%E5%92%8C%E4%BE%A6%E5%90%AC%E5%99%A8watch/">
                        <span class="hidden-mobile">vue计算属性computed和侦听器watch</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  

  

  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  <script  src="/js/local-search.js" ></script>



  
    <script  src="/js/img-lazyload.js" ></script>
  



  



  
    <script  src="https://cdn.jsdelivr.net/npm/tocbot@4/dist/tocbot.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4/anchor.min.js" ></script>
  
  
    <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js" ></script>
  






  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
        typing(title);
      
    })(window, document);
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>


</body>
</html>
